import Vue from 'vue'
import Router from 'vue-router'
import Login from '@/views/Login'
import Layout from '@/views/layout/Layout'
// import

Vue.use(Router)

// 将路由声明为常量，为了动态添加meta信息
export const asyncRoute = [{
  path: '/index',
  name: 'index',
  component: () => import('@/views/index/Index')
}, {
  path: '/userList',
  name: 'userList',
  component: () => import('@/views/user/UserList')
}, {
  path: '/authList',
  name: 'authList',
  component: () => import('@/views/auth/AuthList')
}, {
  path: '/auth/treetable',
  name: 'authTree',
  component: () => import('@/views/auth/AuthTreeTable')
}, {
  path: '/dept/treetable',
  name: 'deptTree',
  component: () => import('@/views/dept/Dept')
}, {
  path: '/gen/table',
  name: 'genTable',
  component: () => import('@/views/gen/TableList')
}, {
  path: '/gen/column',
  name: 'genColumn',
  component: () => import('@/views/gen/ColumnList')
}, {
  path: '/genLog/list',
  name: 'genLog',
  component: () => import('@/views/gen/GenLog')
}, { // 角色管理
  path: '/role/list',
  name: 'roleList',
  component: () => import('@/views/role/Role')
}, {
  path: '/report/city',
  name: 'CityAir',
  component: () => import('@/views/report/CityAir')
}, { // 数据字典
  path: '/dict/list',
  name: 'dictList',
  component: () => import('@/views/dict/Dict')
}, { // 行政区域
  path: '/area/tree',
  name: 'areaList',
  component: () => import('@/views/area/Area')
}, { // 书籍分类
  path: '/category/list',
  name: 'categoryList',
  component: () => import('@/views/category/Category')
}, { // 书籍管理
  path: '/book/list',
  name: 'bookList',
  component: () => import('@/views/book/Book')
}// route
]

export const constantRouter = [
  {
    path: '/dict/info',
    name: 'dictInfo',
    component: () => import('@/views/dict/DictInfo'),
    meta: {title: '字典详细信息'}
  }, {
    path: '/gen/column/:tableName',
    name: 'genColumn',
    component: () => import('@/views/gen/ColumnList'),
    meta: {title: 'gen'}
  }, {
    path: '/userinfo',
    name: 'userinfo',
    component: () => import('@/views/userinfo/Userinfo'),
    meta: {title: '个人中心'}
  }, {
    path: '/404',
    name: '404',
    component: () => import('@/views/error/404'),
    meta: {title: '404'}
  }, {
    path: '*',
    redirect: '/404'
  }
]

export default new Router({
  routes: [
    {
      path: '/',
      name: 'main',
      component: Layout,
      redirect: '/index'
    }, {
      path: '/login',
      name: 'login',
      component: Login
    }
  ]
})
